using System.Collections.Generic;
using Sustainalytics.Entities;
using Sustainalytics.Synchronization.Validation.Entities.CorporateGovernance;
using Sustainalytics.Synchronization.Validation.ValidationRules.CorporateGovernance;
using Xunit;

namespace Sustainalytics.Synchronization.Validation.Tests
{
    [Trait("Category", "Unit")]

    public class GovernanceIndicatorScoreChangeRedRule_should
    {
        private readonly GovernanceIndicatorScoreChangeRedRule _sut = new GovernanceIndicatorScoreChangeRedRule();

        [Fact]
        public void Return_false_when_score_change_equals_100_points()
        {
            var fake = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                                          {
                                                              new GovernanceIndicator { Number = "G.1.1", Score = 0 },
                                                              new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                                              new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                                          }
            };

            var mock = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                                          {
                                                              new GovernanceIndicator { Number = "G.1.1", Score = 100 },
                                                              new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                                              new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                                          }
            };
            var actual = _sut.IsValid(fake, mock);
            Assert.False(actual);
        }

        [Fact]
        public void Return_true_when_score_change_is_lower_than_100_points()
        {
            var fake = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                                          {
                                                              new GovernanceIndicator { Number = "G.1.1", Score = 0 },
                                                              new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                                              new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                                          }
            };

            var mock = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                                          {
                                                              new GovernanceIndicator { Number = "G.1.1", Score = 90 },
                                                              new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                                              new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                                          }
            };
            var actual = _sut.IsValid(fake, mock);
            Assert.True(actual);
        }
    }
}